Skip to content

MM-573: Sanitize tenant and auth headers to prevent header injection#2025

Open
Divyateja2709 wants to merge 2 commits into
openMF:devfrom
Divyateja2709:pr-1
Open

MM-573: Sanitize tenant and auth headers to prevent header injection#2025
Divyateja2709 wants to merge 2 commits into
openMF:devfrom
Divyateja2709:pr-1

Conversation

@Divyateja2709

Copy link
Copy Markdown

hi @therajanmaurya sir

This PR introduces a focused security hardening update in the network layer for MM-573 (Cipher 2026 remediation).
It sanitizes dynamic header values before request injection to reduce malformed-input and header-injection risk.

Changes included
Updated core/network/src/commonMain/kotlin/org/mifospay/core/network/config/InstanceConfigManager.kt

Sanitized platformTenantId in getPlatformTenantId()
Added normalization: trim, remove CR/LF, apply max length cap
Enforced tenant format: [A-Za-z0-9_-]+
Added safe fallback to default tenant when value is empty/invalid
Updated core/network/src/commonMain/kotlin/org/mifospay/core/network/utils/KtorInterceptor.kt

Added sanitizeHeaderValue() helper
Sanitized token before setting Authorization header in both interceptor paths
Skipped Authorization header when sanitized token becomes empty
Why this change
Prevents CR/LF-based header injection vectors in tenant/token values
Improves robustness when config or stored token data is malformed
Keeps scope intentionally small and low-risk for fast review
Validation
IDE lint checks on edited files passed (no new lint issues)
Full build/test execution was not run in this environment due to missing JAVA_HOME

@Divyateja2709
Divyateja2709 requested a review from a team May 10, 2026 13:45
@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Divyateja2709 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 44 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a53272c4-2fe7-4d1b-9e6a-471dc6cc3cfb

📥 Commits

Reviewing files that changed from the base of the PR and between d399e0a and cbb9b99.

📒 Files selected for processing (2)
  • core/network/src/commonMain/kotlin/org/mifospay/core/network/config/InstanceConfigManager.kt
  • core/network/src/commonMain/kotlin/org/mifospay/core/network/utils/KtorInterceptor.kt
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant